import instance from "@/utils/request";
enum API{
     ROLEUSERLIST_URL='/admin/acl/role',
     ADDROLE_URL='/admin/acl/role/save',
     UPDATEROLE_URL='/admin/acl/role/update',
     GETALLROLE_URL='/admin/acl/permission/toAssign',
     SETPERMISTION_URL='/admin/acl/permission/doAssign',
     DELETEROLE_URL='/admin/acl/role/remove'
}

// 获取
export const RoleUserListAPI=(page:number,limit:number,roleName?:string)=>{
  return instance.get(API.ROLEUSERLIST_URL+`/${page}/${limit}/?roleName=${roleName}`)
}

// 添加
export const AddRoleAPI=(data:any)=>{
   return instance.post(API.ADDROLE_URL,data)
}

// 修改
export const EditRoleAPI=(data:any)=>{
  return instance.post(API.UPDATEROLE_URL,data)
}

// 获取全部权限
export const GetAllRoleAPI=(roleId:number)=>{
  return instance.get(API.GETALLROLE_URL+`/${roleId}`)
}
// 配置权限
export const SetRoleAPI=(roleId:number,permissionId:number[])=>{
  return instance.post(API.SETPERMISTION_URL+`/?roleId=${roleId}&permissionId=${permissionId}`)
}

// 删除
export const DeleteRoleAPI=(roleId:number)=>{
  return instance.delete(API.DELETEROLE_URL+`/${roleId}`)
}
